﻿package org.cshoo.sys.business.service;

import java.util.List;

import org.cshoo.sys.business.iservice.IDictionaryService;
import org.cshoo.sys.data.entity.Dictionary;
import org.cshoo.sys.data.idao.IDictionaryDAO;

/**
 * @author 杨翼
 * 2013年10月4日
 */
public class DictionaryService implements IDictionaryService{
	
	private IDictionaryDAO dictionaryDAO;

	public void setDictionaryDAO(IDictionaryDAO dictionaryDAO) {
		this.dictionaryDAO = dictionaryDAO;
	}
	
	/**
	 * 添加一个字典信息
	 * @param dictionary
	 * @return
	 */
	public Boolean addDictionary(Dictionary dictionary){
		Boolean result = false;
		dictionaryDAO.addObject(dictionary);
		result = true;
		return result;
	}
	
	/**
	 * 查询字典
	 * @param dictionaryExample
	 * @return
	 */
	public List findDictionaryList(Dictionary dictionaryExample){
		return dictionaryDAO.findObjectListByExample(dictionaryExample);
	}
	
	/**
	 * 按照条件分批查询
	 * @param firstResult
	 * @param maxResults
	 * @return 
	 */
	public List findDictionaryBatcheList(int firstResult,int maxResults){
		return dictionaryDAO.findDictionaryBatcheList(firstResult, maxResults);
	}
	
	
	/**
	 * 根据字典例子分批查询
	 * @param dictionaryExample 字典的例子
	 * @param firstResult 开始记录数
	 * @param maxResults 要查询的总记录数
	 * @return
	 */
	public Object[] findDictionaryBatcheArrayByExample(Dictionary dictionaryExample,int firstResult,int maxResults)
	{
		Object[] result = new Object[2];
		result[0] = dictionaryDAO.getObjectCountByExample(dictionaryExample);
		result[1] = dictionaryDAO.findObjectBatcheListByExample(dictionaryExample, firstResult, maxResults);
		return result;
	}
	
	 
	/**
	 * 修改一个字典信息
	 * @param dictionary
	 * @return
	 */
	public Boolean updateDictionary(Dictionary dictionary){
		Boolean result = false;
		dictionaryDAO.updateObject(dictionary);
		result = true;
		return result;
	}
	
	/**
	 * 删除一个字典信息
	 * @param dictionary
	 * @return
	 */
	public Boolean deleteDictionary(Dictionary dictionary){
		Boolean result = false;
		dictionaryDAO.deleteObject(dictionary);
		result = true;
		return result;
	}
	
	
}
